//
//  SAWCorrectModel.m
//  BestLearning
//
//  Created by edz on 2018/2/1.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "SAWCorrectModel.h"

@implementation SAWCorrectModel
-(void)dataWithOrder:(void(^)(NSArray *dataArr))dataBlock withpage:(NSInteger)page withSearchName:(NSString *)searchName withFild:(void(^)())filedBlock
{
    NSString *str = [NSString stringWithFormat:@"assignHomework.do?action=getWorkLessonList&name=%@&pageNumber=%ld",searchName.length>0 ? searchName : @"",page];
    
    NSString *url  = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    [SVProgressHUD setDefaultStyle:(SVProgressHUDStyleCustom)];
    [SVProgressHUD  setBackgroundColor:ColorRGB(4, 4, 4)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
    [SVProgressHUD showWithStatus:LLLoading];
    
    NSLog(@"%@  %@",LLBaseURL(url),[AccountTool shareAccountTool].currentAccount.authCode);
    [NetManager Get:LLBaseURL(url) Auth:YES Params:nil Success:^(id Obj) {
        if ([[Obj valueForKey:@"code"] integerValue] == 1000) {
            
            if (dataBlock) {
                dataBlock(Obj[@"t"][@"dataList"]);
            }
            [SVProgressHUD dismiss];
            
            
        }
        else
        {
            if (filedBlock) {
                filedBlock();
            }
            [SVProgressHUD showErrorWithStatus:Obj[@"msg"]];
        }
    } Fail:^(NSError *Error) {
        if (filedBlock) {
            filedBlock();
        }
        [SVProgressHUD showErrorWithStatus:Error.userInfo[@"NSLocalizedDescriptionKey"]];
    }];
    
}
//错题集中营
-(void)CorrectHomeWork:(void(^)(NSArray *dataArr))dataBlock withpage:(NSInteger)page withSearchName:(NSString *)lessId withFild:(void(^)())filedBlock
{
    NSString *url = [NSString stringWithFormat:@"assignHomework.do?action=getWorkPointList&lessonId=%@&type=0",lessId];
    
   
    
    [SVProgressHUD setDefaultStyle:(SVProgressHUDStyleCustom)];
    [SVProgressHUD  setBackgroundColor:ColorRGB(4, 4, 4)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
    [SVProgressHUD showWithStatus:LLLoading];
    
    NSLog(@"%@  %@",LLBaseURL(url),[AccountTool shareAccountTool].currentAccount.authCode);
    [NetManager Get:LLBaseURL(url) Auth:YES Params:nil Success:^(id Obj) {
        if ([[Obj valueForKey:@"code"] integerValue] == 1000) {
            
            if (dataBlock) {
                dataBlock(Obj[@"t"]);
            }
            [SVProgressHUD dismiss];
            
            
        }
        else
        {
            if (filedBlock) {
                filedBlock();
            }
            [SVProgressHUD showErrorWithStatus:Obj[@"msg"]];
        }
    } Fail:^(NSError *Error) {
        if (filedBlock) {
            filedBlock();
        }
        [SVProgressHUD showErrorWithStatus:Error.userInfo[@"NSLocalizedDescriptionKey"]];
    }];
    
}
//知识点分值库

-(void)KnowHomeWork:(void(^)(NSArray *dataArr))dataBlock withpage:(NSInteger)page withSearchName:(NSString *)lessId withFild:(void(^)())filedBlock
{
    NSString *url = [NSString stringWithFormat:@"assignHomework.do?action=getWorkPointList&lessonId=%@&type=1",lessId];
    
    
    
    [SVProgressHUD setDefaultStyle:(SVProgressHUDStyleCustom)];
    [SVProgressHUD  setBackgroundColor:ColorRGB(4, 4, 4)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
    [SVProgressHUD showWithStatus:LLLoading];
    
    NSLog(@"%@  %@",LLBaseURL(url),[AccountTool shareAccountTool].currentAccount.authCode);
    [NetManager Get:LLBaseURL(url) Auth:YES Params:nil Success:^(id Obj) {
        if ([[Obj valueForKey:@"code"] integerValue] == 1000) {
            
            if (dataBlock) {
                dataBlock(Obj[@"t"]);
            }
            [SVProgressHUD dismiss];
            
            
        }
        else
        {
            if (filedBlock) {
                filedBlock();
            }
            [SVProgressHUD showErrorWithStatus:Obj[@"msg"]];
        }
    } Fail:^(NSError *Error) {
        if (filedBlock) {
            filedBlock();
        }
        [SVProgressHUD showErrorWithStatus:Error.userInfo[@"NSLocalizedDescriptionKey"]];
    }];
}
//作业详情
-(void)HomeWorkDetail:(void(^)(NSArray *dataArr))dataBlock withpage:(NSString *)lessID withSearchName:(NSString *)Id withFild:(void(^)())filedBlock
{
    NSString *url = [NSString stringWithFormat:@"user.do?action=getHomeWorkList&lessonId=%@&knowledgeId=%@",lessID,Id];
    
    
    
    [SVProgressHUD setDefaultStyle:(SVProgressHUDStyleCustom)];
    [SVProgressHUD  setBackgroundColor:ColorRGB(4, 4, 4)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
    [SVProgressHUD showWithStatus:LLLoading];
    
    NSLog(@"%@  %@",LLBaseURLs(url),[AccountTool shareAccountTool].currentAccount.authCode);
    [NetManager Get:LLBaseURLs(url) Auth:YES Params:nil Success:^(id Obj) {
        if ([[Obj valueForKey:@"code"] integerValue] == 1000) {
            
            if (dataBlock) {
                dataBlock(Obj[@"t"][@"dataList"]);
            }
            [SVProgressHUD dismiss];
            
            
        }
        else
        {
            if (filedBlock) {
                filedBlock();
            }
            [SVProgressHUD showErrorWithStatus:Obj[@"msg"]];
        }
    } Fail:^(NSError *Error) {
        if (filedBlock) {
            filedBlock();
        }
        [SVProgressHUD showErrorWithStatus:Error.userInfo[@"NSLocalizedDescriptionKey"]];
    }];
}
@end
